package invest.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CodeConverterUtil {
    public static String convertCode(String code) {
        boolean flag = false;
        Pattern p = Pattern.compile(".*\\d+.*");
        Matcher m = p.matcher(code);
        if (m.matches()) {
            flag = true;
        }
        if (flag) {
            String regEx = "[^0-9]";
            Pattern p2 = Pattern.compile(regEx);
            Matcher m2 = p2.matcher(code);
            return m2.replaceAll("").trim();
        } else {
            return code;
        }

    }
}
